<style lang="scss" scoped>
.s-body{
  background: #fff;
}
</style>

<template>
  <view class="page">
    <view class="s-head">
      <h-head :back="true">
        {{ tit }}
      </h-head>
    </view>

    <view class="s-body">
      <scroll-view class="maxh" :scroll-y="true">
        <web-view v-if="info.openType === 1" :src="jumpUrl"></web-view>
        <u-parse v-if="info.openType === 2" :html="info.content"></u-parse>
      </scroll-view>
    </view>
  </view>
</template>

<script>
export default {
  name: "agreement",
  onLoad({type}) {
    const config = this.storage.getConfig()
    this.jumpUrl = config.jumpUrl

    const obj = {
      1: '用户协议',
      2: '隐私政策',
      3: '联系客服',
      4: '关于我们',
      5: '使用教程',
      6: '推广协议',
      7: '会员协议',
    }
    this.tit = obj[type]

    this.httpClient.post({
      url: this.APIPath.agreement.detail,
      data: {
        type
      }
    }).then(res => {
      this.info = res.data
      if(this.info.openType === 1) {
        if(this.jumpUrl) {
          this.jumpUrl += '?url=' + encodeURIComponent(this.info.url)
        }else{
          this.jumpUrl += this.info.url
        }
      }
    }, err => {
    })

  },
  data() {
    return {
      jumpUrl: '',
      tit: '',
      info: {}
    }
  },
  methods: {}
}
</script>
